@/*
    select标签中各个参数的说明:
    name : select的名称
    id : select的id
    hasEmpty:false
    code : 字典的code
    map : 选项map 示例：{'1':'目录','2':'菜单','3':'权限'};
    url: 动态选项地址
    key: 动态key
    text: 动态text
    pid:
@*/
@if(isNotEmpty(widgetParam)){
	@var _wpMap = {};
	@var _tmpLs = strutil.split(widgetParam,",");
	@for(ele in _tmpLs){
		@var _ele = strutil.split(ele,"=");
		@_wpMap[_ele[0]]=_ele[1];
	@}
    @code = _wpMap["code"];
    @url = _wpMap["url"];
    @key = _wpMap["key"];
    @text = _wpMap["text"];
    @pid = _wpMap["pid"];
    @hasEmpty = _wpMap["hasEmpty"];
@}
@hasEmpty = isEmpty(hasEmpty)?'true':hasEmpty;
@hasEmpty = hasEmpty=='true'?true:false;

<div class="form-group">
	@if(!isEmpty(name)){
	<label for="${id}" class="control-label">${name}</label>
	@}
    <select class="hisui-combobox" id="${id}" name="${id}"
		@if(isEmpty(width)){
		@	width="160px";
		@}
        style="width:${width!}"
    >
    	@var _map = null;
		@if(isNotEmpty(map)){
			@_map = map;
		@}
		@if(isNotEmpty(code)){
			@_map = getDictsByCode(code);
		@}
		@if(hasEmpty){
			<option value="">全部</option>
		@}
		@if(isEmpty(_map)){
			${tagBody!}
		@}else{
			@for(ele in _map){
				@if((ele.key+'')==(value!''+'')){
					<option value="${ele.key}" selected = "selected" >${ele.value}</option>
				@}else{
					<option value="${ele.key}">${ele.value}</option>
				@}
			@}
		@}
    </select>
</div>
@if(isNotEmpty(key) && isNotEmpty(text)){
<script>
/**
*url 请求地址
*params 请求参数
*defVal 默认值
*hasNone 是否有空项
*/
var ${id}_loadOptions=function(url,params,defVal,hasNone){
	//$("#${id}").html(hasNone?"<option value=''></option>":"");
	$.ajax({
		url : url,
		async : false,
		cache : false,
		data : params?params:{},
		success : function(data) {
			$.each(data,function(i,n){
				var _opt = $("<option value='"+n['${key}']+"'>"+n['${text}']+"</option>")
				
				if(defVal && defVal==(n['${key}']+"")){
					_opt.attr("selected","selected");
				}
				$("#${id}").append(_opt);
			});
		}
	})
}
var ${id}_defVal = "";
@if(isNotEmpty(value)){
${id}_defVal = "${value}";
@}
//$(document).ready(function(){
@if((isNotEmpty(url)&&isEmpty(pid)&&isEmpty(value))||(isNotEmpty(url)&&isNotEmpty(value))){
	var _params = null;
@if(isNotEmpty(pid)){
	_params = {"${pid}": ${pid}_defVal};
@}
	${id}_loadOptions("${url}",_params,'${value!}',true);
@}
@if(isNotEmpty(pid)){
    $("#${pid}").change(function(){
    	if($("#${pid}").val()!=""){
        	${id}_loadOptions("${url}",{"${pid}":$("#${pid}").val()},null,true);
    	}
    })
@}
//})
</script>
@}
